# Huawei Technologies Co.,Ltd.

set(JS_TYPED_ARRAYS_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/js_typed_arrays.txt)
set(JS_TYPED_ARRAYS_BIN ${CMAKE_CURRENT_BINARY_DIR}/js_typed_arrays.abc)
set(JS_TYPED_ARRAYS_JS ${CMAKE_CURRENT_SOURCE_DIR}/js_typed_arrays.js)
set(JS_TYPED_ARRAYS_VERIFY ${CMAKE_CURRENT_SOURCE_DIR}/verify.sh)

set(RUNTIME_ARGUMENTS --boot-panda-files=${CMAKE_BINARY_DIR}/pandastdlib/arkstdlib.abc --compiler-enable-jit=false --run-gc-in-place --load-runtimes \"ecmascript\" ${JS_TYPED_ARRAYS_BIN} _GLOBAL::func_main_0)

add_custom_command(
    OUTPUT ${JS_TYPED_ARRAYS_OUTPUT}
    COMMENT "running javascript js_typed_arrays testcase"
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:es2panda> ${JS_TYPED_ARRAYS_JS}  --output ${JS_TYPED_ARRAYS_BIN}
    COMMAND rm -f ${JS_TYPED_ARRAYS_OUTPUT}
    COMMAND ${PANDA_RUN_PREFIX} $<TARGET_FILE:ark> ${RUNTIME_ARGUMENTS} 2>&1 > ${JS_TYPED_ARRAYS_OUTPUT}
    COMMAND bash ${JS_TYPED_ARRAYS_VERIFY} ${JS_TYPED_ARRAYS_OUTPUT}
)
add_custom_target(js_typed_arrays
    DEPENDS ${JS_TYPED_ARRAYS_OUTPUT} ${JS_TYPED_ARRAYS_VERIFY}
)
add_dependencies(js_typed_arrays es2panda ark)
add_dependencies(ecmascript_common_tests js_typed_arrays)
